package org.xtense.tests;

import java.util.List;

import org.dom4j.Attribute;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.Node;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter;
import org.xtense.data.DBManager;
import org.xtense.engine.actions.QueryAction;
import org.xtense.engine.actions.UpdateAction;

public class QueryEngineTest {
	public static void main(String [] args) throws Exception{
		DBManager m = new DBManager();
		QueryAction s = new QueryAction("books.xml");
		Element root = (Element) ((List<Node>) s.execute("/")).get(0);
		// Element toadd = DocumentHelper.createElement("iamsuperman");
		// toadd.addText("fuckyou");
		// toadd.add(DocumentHelper.createAttribute(toadd, "what", "dammmm"));
		// toadd.add(DocumentHelper.createElement("what"));
		// toadd.add(DocumentHelper.createElement("sadfljlzxcvj"));
		// root.add(toadd);
		int le = root.elements().size();
		Element test = (Element) root.elements().get(1);
		test.detach();

				
		
		
		UpdateAction.getInstance(1).execute(null);
		



								root = (Element) ((List<Node>) s.execute("/")).get(0);

		OutputFormat format = OutputFormat.createPrettyPrint();
		XMLWriter writer = new XMLWriter(System.out, format);
		writer.write(root);

		Attribute att = DocumentHelper.createAttribute(null, "xxx", "asdfsadf");
	}
	
}
